from django.shortcuts import render, get_object_or_404
from .models import Categroy, Article, Comments


def index(request):
    '''主页信息'''
    post_list = Article.objects.all()
    context = {'post_list': post_list}
    return render(request, 'blog/index.html', context)


def Archives(request, year, month):
    '''时间排序'''
    post_list = Article.objects.filter(created__year=year,
                                    created__month=month,)
    context= {'post_list': post_list}
    return render(request, 'blog/index.html', context)



def detail(request, Article_id):
    '''文章内容'''
    article = get_object_or_404(Article, pk=pk)
    body = Article.objects.get(pk=pk)
    context = {'post_detail': post_detail}
    return render(request, 'blog/detail.html', context)


def post_theme(request):
    '''博客主题'''
    #blog_theme = Category.objects.all()
    #context = ('bolg_theme', blog_theme)
    #return render(request, 'blog/category.html', context)


def Comment(request):
    pass
